﻿namespace GraphEntities
    
open System
open System.Collections.Generic
open NumericalFunctions
open System.Windows.Forms.DataVisualization.Charting


    type TwoDimensionalFunctionPoint  = 
            inherit Point
            public new (f:Func<float,float>, x:float) ={inherit Point(x, f.Invoke(x))}
            public new (x,y) = {inherit Point(x, y)}
            member public this.CompleteTuple() = (this.X,this.Y)

    type TwoDimentionalFunctionData = 
        inherit Points
        val mutable m_graphName:string

        new (f:Func<float,float>, startX, stopX, accuracy, graphName:string) = 
            let points = 
                FunctionValues.CreateFunctionValuesTable(f,startX,stopX,accuracy) |>
                Array.map(fun (x,y) ->
                            [|x;y|]
                        )
            {
                inherit Points(points);
                m_graphName = graphName;
            }
        new () = 
            {
                inherit Points();
                m_graphName = ""
            }

        member this.GraphName with get()       = this.m_graphName 
                              and  set(name)   = this.m_graphName <- name
        member this.GenerateSeries (chartType:SeriesChartType) = 
            let newSeria = new Series(this.GraphName, this.Count);
            newSeria.ChartType <- chartType;
            for point in this.PointList do
                let dataPoint = new DataPoint(point.X, point.Y);
                newSeria.Points.Add(dataPoint);
            newSeria